//AI自爆
params["_bomber", "_dis", ["_daed", false]];

_dis = _dis * _dis;

private ["_expl1", "_expl2", "_expl3"];
//绑上炸弹
_expl1 = "DemoCharge_Remote_Ammo" createVehicle position _bomber;
_expl1 attachTo [_bomber, [-0.1, 0.1, 0.15], "Pelvis"];
[_expl1, [ [0.5, 0.5, 0], [-0.5, 0.5, 0] ]] remoteExec["setVectorDirAndUp", 0];
_expl1 setVariable ["no_cleanup", true];
_expl1 allowDamage false;

_expl2 = "DemoCharge_Remote_Ammo" createVehicle position _bomber;
_expl2 attachTo [_bomber, [0, 0.15, 0.15], "Pelvis"];
[_expl2, [ [1, 0, 0], [0, 1, 0] ]] remoteExec["setVectorDirAndUp", 0];
_expl2 setVariable ["no_cleanup", true];
_expl2 allowDamage false;

_expl3 = "DemoCharge_Remote_Ammo" createVehicle position _bomber;
_expl3 attachTo [_bomber, [0.1, 0.1, 0.15], "Pelvis"];
[_expl3, [ [0.5, -0.5, 0], [0.5, 0.5, 0] ]] remoteExec["setVectorDirAndUp", 0];
_expl3 setVariable ["no_cleanup", true];
_expl3 allowDamage false;


private _doBoom = false;
while{!_doBoom} do
{
	waitUntil{sleep 10;simulationEnabled _bomber};
	if(!alive _bomber) exitWith
	{
		_doBoom = true;
	};
	
	{
		if(alive _x
		&& {_x getVariable ['FAR_isUnconscious',1] == 0}
		&& {_x distanceSqr _bomber < _dis})exitWith{
			[_bomber, ["snackbar", 40]] remoteExec ["say3d", 0];
			_doBoom = true;
		};
	}forEach (call fn_getPlayerRed);
	Sleep 2;
};

private _bomb = "Bomb_03_F" createVehicle (getPos _bomber);//Bo_GBU12_LGB_MI10
_bomb setDamage 1;

deleteVehicle _expl1;
deleteVehicle _expl2;
deleteVehicle _expl3;

if(_daed)then{_bomber setDamage 1;};